package com.mystnihon.provider;

import android.content.ContentProvider;
import android.content.Context;
import android.content.UriMatcher;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.net.Uri;

public abstract class RawQueryProvider extends ContentProvider {

    protected SQLiteDatabase mDatabase;
    protected static final String DATABASE_NAME = "database.sqlite";
    protected static final int DATABASE_VERSION = 0;
    protected static final String AUTHORITY = "com.mystnihon.provider.RawQueryProvider_Authority";

    protected static final UriMatcher sURIMatcher = new UriMatcher(UriMatcher.NO_MATCH);

    protected static final String RAW_QUERY_ACTION = "rawquery";
    protected static final int RAWQUERY_ID = 0x9900;
    public static final Uri RAW_QUERY_URI = Uri.parse("content://" + AUTHORITY + "/" + RAW_QUERY_ACTION);

    static {
        // URI matching table
        UriMatcher matcher = sURIMatcher;

        // Raw query
        matcher.addURI(AUTHORITY, RAW_QUERY_ACTION, RAWQUERY_ID);

    }

    @Override
    public int delete(Uri arg0, String arg1, String[] arg2) {
        // TODO Auto-generated method stub
        return 0;
    }

    @Override
    public String getType(Uri uri) {
        final int match = sURIMatcher.match(uri);
        switch (match) {
            case RAWQUERY_ID:
                return "vnd.android.cursor.item/vnd.bytel." + "rawquery";
            default:
                throw new IllegalArgumentException("Unknown URI " + uri);
        }
    }

    @Override
    public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) {
        // TODO Auto-generated method stub
        return null;
    }

    public abstract SQLiteDatabase getDatabase(final Context context);

}
